import cv2 as cv

# r表示去掉所有的转译

fileName = r"lena.jpg"
img = cv.imread(fileName)
imgGauss = cv.GaussianBlur(img, (5, 5), 0)
image1 = cv.resize(img, (int(img.shape[1] / 2), int(img.shape[0] / 2)))
image2 = cv.pyrDown(image1)
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
_,gray1 = cv.threshold(gray, 120, 0xff, cv.THRESH_BINARY)

cv.imshow("source img", img)
#cv.imshow("Gaussion filtered img", imgGauss)
#cv.imshow("half size", image1)
#cv.imshow("quater size", image2)
#cv.imshow("gray", gray)
#cv.imshow("threshold img", gray1)


hsv = cv.cvtColor(img, cv.COLOR_BGR2HSV)

# 色度
cv.imshow("Hue", hsv[:, :, 0])
# 饱和度
cv.imshow("Saturation", hsv[:, :, 1])
# 亮度
cv.imshow("Value", hsv[:, :, 2])


cv.imshow("blue", img[:, :, 0])
cv.imshow("green", img[:, :, 1])
cv.imshow("red", img[:, :, 2])
cv.waitKey()

cv.destroyWindow()
